//
// register.js
// hs-admin
//
// Created by 区区电脑 on 2023/07/19.
//

import AMapLoader from "@amap/amap-jsapi-loader"
import {AMap_App, AMap_App_2, AMap_App_3} from "./config.js"
import AMapComponent from "./AMap.vue"

window._AMapSecurityConfig = AMap_App_3
export default function registerAMap(app) {
    app.component("AMap", AMapComponent)
    // 挂载 高德地图
    AMapLoader.load({
        "key": window._AMapSecurityConfig.key,
        "version": "2.0",
        "plugins": ["AMap.DistrictSearch", "AMap.Scale", "AMap.ToolBar", "AMap.ControlBar", "AMap.AutoComplete", "AMap.Driving", "AMap.Geolocation", "AMap.ContextMenu", "AMap.MoveAnimation", "AMap.MarkerCluster"],
        AMapUI: {
            version: "1.1",
            plugins: ["misc/PositionPicker"]
        }
    }).then((AMap) => {
        window.AMap = AMap
        window.dispatchEvent(new CustomEvent('onamap'));
    }).catch(e => {
        console.danger('高德地图出错', e);
    })
}
